import React, { Component } from "react";

export default class NotControlledCom2 extends Component {

  register=()=>{
    console.log('用户名：',this.nameRef.value);
    console.log('密码:',this.pwdRef.value);
  }
  render() {
    return (
      <div>
        <h1>非受控</h1>
        <div>
          <label htmlFor="username">姓名：</label>
          <input type="text" id="username" ref={a=>this.nameRef=a}/>
        </div>
        <div>
          <label htmlFor="password">密码</label>
          <input type="text" id="password" ref={e=>this.pwdRef=e}/>
        </div>
        <div>
          <button onClick={this.register}>注册</button>
        </div>
      </div>
    );
  }
}
